//
//  ALPS_ListenTableViewCell.m
//  Alps
//
//  Created by dllo on 16/6/8.
//  Copyright © 2016年 dllo. All rights reserved.
//

#import "ALPS_ListenTableViewCell.h"

@implementation ALPS_ListenTableViewCell

- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier
{
    self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
    if (self) {
        self.leftImageView = [[UIImageView alloc] initWithFrame:CGRectMake(10, 10, ScreeHeight / 6.67 - 20, ScreeHeight / 6.67 - 20)];
        [self.contentView addSubview:_leftImageView];
        
        self.titleLabel = [[UILabel alloc] init];
        self.titleLabel.font = [UIFont systemFontOfSize:15];
        self.titleLabel.numberOfLines = 2;
        [self.contentView addSubview:_titleLabel];
        [self.titleLabel mas_makeConstraints:^(MASConstraintMaker *make) {
            make.edges.mas_offset(UIEdgeInsetsMake(10, ScreeHeight / 6.67 , ScreeHeight / 6.67 - 40, 40));
        }];
        
        self.introLabel = [[UILabel alloc] init];
        self.introLabel.font = [UIFont systemFontOfSize:14];
        self.introLabel.textColor = [UIColor grayColor];
        [self.contentView addSubview:_introLabel];
        [self.introLabel mas_makeConstraints:^(MASConstraintMaker *make) {
            make.edges.mas_offset(UIEdgeInsetsMake(ScreeHeight / 16.675, ScreeHeight / 6.67, ScreeHeight / 6.67 - ScreeHeight / 11.17, 40));
        }];
        
        self.playImageView = [[UIImageView alloc] init];
        [self.contentView addSubview:_playImageView];
        [self.playImageView mas_makeConstraints:^(MASConstraintMaker *make) {
            make.edges.mas_offset(UIEdgeInsetsMake(ScreeHeight / 6.67 - 25, ScreeHeight / 6.67, 10, ScreeWidth - ScreeHeight / 6.67 - 15));
        }];
        
        self.playCountLabel = [[UILabel alloc] init];
        self.playCountLabel.font = [UIFont systemFontOfSize:14];
        self.playCountLabel.textColor = [UIColor grayColor];
        [self.contentView addSubview:_playCountLabel];
        [self.playCountLabel mas_makeConstraints:^(MASConstraintMaker *make) {
            make.edges.mas_offset(UIEdgeInsetsMake(ScreeHeight / 6.67 - 30, ScreeHeight / 6.67 + 15, 5, ScreeWidth / 1.97));
        }];
        
        self.lineLabel = [[UILabel alloc] init];
        self.lineLabel.backgroundColor = [UIColor colorWithRed:0.9 green:0.9 blue:0.9 alpha:1];
        [self.contentView addSubview:_lineLabel];
        [self.lineLabel mas_makeConstraints:^(MASConstraintMaker *make) {
            make.edges.mas_offset(UIEdgeInsetsMake(ScreeHeight / 6.67 - 1, 100, 0, 0));
        }];
    }
    return self;
}

- (void)setModel:(ALPS_ListenModel *)model
{
    if (_model != model) {
        _model = model;
        [self.leftImageView sd_setImageWithURL:[NSURL URLWithString:model.coverPathSmall]];
        self.titleLabel.text = model.title;
        self.introLabel.text = model.subtitle;
        self.playImageView.image = [UIImage imageNamed:@"find_specialicon"];
        self.playCountLabel.text = model.footnote;
    }
}


- (void)awakeFromNib {
    [super awakeFromNib];
    // Initialization code
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}

@end
